http://learn-share.net/programming-basics-course/
Programming Course. The Basics of Programming.
#28 String Concatenation
Learn to code.
Cleaning up with string concatenation
As we know, Java_script is a weakly type language, meaning, our variables can hold numbers, strings, booleans. But java_script still cares, and treats does values differently.
Let’s see an example.
If we create two variables, foo, and bar, and we give numeric values. The number 5 without double quotes.
Then we call alert, adding him together, using the addition operator.
What we get, will be the number 5.
He understands this is numbers, and add them together.
On the other hand, if we create this variables with the digit 5, but inside double quotes, as a string.
And then we use the same code, the addition operator, to add him together. What’s going to happen is concatenation, not addition. He put them side by side, given the result 55.
Now what happen if you got one of each.
So what happen if one variable is a number and the other is a string.
If one is a string, that going to take charge, and you get concatenation.
…